<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
		<!-- 因为 AJAX 库和通用工具的生态已经相当丰富，Vue 核心代码没有重复 -->
		<!-- 提供这些功能以保持精简。这也可以让你自由选择自己更熟悉的工具。 -->
		<script src="https://cdn.jsdelivr.net/npm/axios@0.12.0/dist/axios.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/lodash@4.13.1/lodash.min.js"></script>

	</head>
	<body>
		<div id="list-demo" class="demo">
			<button @click="add">Add</button>
			<button @click="remove">Remove</button>
			<transition-group name="list" tag="p">
				<span v-for="item in items" v-bind:key="item" class="list-item">
					{{item}}
				</span>
			</transition-group>
		</div>	
		<script type="text/javascript">
			 /**
			  * 列表的进入和离开过度
			  */
			 let app=new Vue({
				 el:'#list-demo',
				 data:{
					 items:[1,2,3,4,5,6,7,8,9],
					 nextNum:10,
				 },
				 methods:{
					radomIndex:function(){
						 return Math.floor(Math.random()*this.items.length);
					},
					add:function(){
						this.items.splice(this.radomIndex(),0,this.nextNum++)
					},
					remove:function(){
						this.items.splice(this.radomIndex(),1)
					}
				 }
				 
			 })
		</script>	
		<style type="text/css">
			.list-item {
			  display: inline-block;
			  margin-right: 10px;
			}
			.list-enter-active, .list-leave-active {
			  transition: all 1s;
			}
			.list-enter, .list-leave-to
			/* .list-leave-active for below version 2.1.8 */ {
			  opacity: 0;
			  transform: translateY(30px);
			}
		</style>
	</body>
</html>
